<template>
	<!-- 楼层区域 -->
	<view>
		<swiper :indicator-dots="true" :autoplay="true" :interval="3000" :duration="1000" :circular="true">
			<swiper-item>
				<navigator class="swiper-item" :url="'/subpkg/goods_detail/goods_detail'">
					<img src="/static/swiper/西门子.webp" />
				</navigator>
			</swiper-item>
			<swiper-item>
				<navigator class="swiper-item" :url="'/subpkg/goods_detail/goods_detail'">
					<img src="/static/swiper/拳王.webp" />
				</navigator>
			</swiper-item>
			<swiper-item>
				<navigator class="swiper-item" :url="'/subpkg/goods_detail/goods_detail'">
					<img src="/static/swiper/雷士.jpg" />
				</navigator>
			</swiper-item>
		</swiper>
	</view>
	<!-- 分类导航区域 -->
	<view class="nav-list">
		<view class="nav-item" @click="navigatorHandler(e)">
			<img src=" /static/nav/分类.png" class="nav-img" />
			<text class="nav-text">分类</text>
		</view>
		<view class="nav-item" @click="navigatorHandler1(e)">
			<img src="/static/nav/家用电器.png" class="nav-img" />
			<text class="nav-text">家庭用品</text>
		</view>
		<view class="nav-item" @click="navigatorHandler2(e)">
			<img src=" /static/nav/绿色工厂.png" class="nav-img" />
			<text class="nav-text">工厂用品</text>
		</view>
		<view class="nav-item" id="1" @click="navigatorHandler3(e)">
			<img src=" /static/nav/照明.png" class="nav-img" />
			<text class="nav-text">照明</text>
		</view>
	</view>
	<!-- 楼层区域 -->
	<!-- 楼层的容器 -->
	<view class="floor-list">
		<!-- 每一个楼层的item项 -->
		<view class="floor-item">
			<!-- 楼层的标题 -->
			<img src="/static/floor/店长推荐.png" class="floor-title" />
			<!-- 楼层的图片区域 -->
			<view class="floor-img-box">
				<!-- 左侧大图片的盒子 -->
				<navigator class="left-img-box" url="/subpkg/goods_list/goods_list?推荐">
					<img src="/static/floor/list/西门子插座.png" style="width:232rpx;height: 470rpx" />
				</navigator>
				<!-- 右侧4个小图片的盒子 -->
				<view class="right-img-box">
					<navigator class="right-img-item" url="/subpkg/goods_list/goods_list?推荐">
						<img src="/static/floor/list/富士灯管.png" style="width:232rpx" mode="widthFix" />
					</navigator>
					<navigator class="right-img-item" url="/subpkg/goods_list/goods_list?推荐">
						<img src="/static/floor/list/富士顶照明.png" style="width:232rpx" mode="widthFix" />
					</navigator>
					<navigator class="right-img-item" url="/subpkg/goods_list/goods_list?推荐">
						<img src="/static/floor/list/红典灯泡.png" style="width:232rpx" mode="widthFix" />
					</navigator>
					<navigator class="right-img-item" url="/subpkg/goods_list/goods_list?推荐">
						<img src="/static/floor/list/雷士照明灯管.png" style="width:232rpx" mode="widthFix" />
					</navigator>
				</view>
			</view>
		</view>
		<!-- 每一个楼层的item项 -->
		<view class="floor-item">
			<!-- 楼层的标题 -->
			<img src="/static/floor/当季热卖2.png" class="floor-title" />
			<!-- 楼层的图片区域 -->
			<view class="floor-img-box">
				<!-- 左侧大图片的盒子 -->
				<navigator class="left-img-box" url="/subpkg/goods_list/goods_list?热卖">
					<image src="/static/floor/list/深思插座金.png" style="width:232rpx;height: 470rpx" />
				</navigator>
				<!-- 右侧4个小图片的盒子 -->
				<view class="right-img-box">
					<navigator class="right-img-item" url="/subpkg/goods_list/goods_list?热卖">
						<image src="/static/floor/list/拳王插座A系列.png" style="width:232rpx" mode="widthFix" />
					</navigator>
					<navigator class="right-img-item" url="/subpkg/goods_list/goods_list?热卖">
						<img src="/static/floor/list/拳王插座Q系列.png" style="width:232rpx" mode="widthFix" />
					</navigator>
					<navigator class="right-img-item" url="/subpkg/goods_list/goods_list?热卖">
						<img src="/static/floor/list/深思插座白.png" style="width:232rpx" mode="widthFix" />
					</navigator>
					<navigator class="right-img-item" url="/subpkg/goods_list/goods_list?热卖">
						<img src="/static/floor/list/深思插座黑.png" style="width:232rpx" mode="widthFix" />
					</navigator>
				</view>
			</view>
		</view>
		<!-- 每一个楼层的item项 -->
		<view class="floor-item">
			<!-- 楼层的标题 -->
			<img src="/static/floor/新品上市.png" class="floor-title" />
			<!-- 楼层的图片区域 -->
			<view class="floor-img-box">
				<!-- 左侧大图片的盒子 -->
				<navigator class="left-img-box" url="/subpkg/goods_list/goods_list?新品">
					<img src="/static/floor/list/红典筒灯.png" style="width:232rpx;height: 470rpx" />
				</navigator>
				<!-- 右侧4个小图片的盒子 -->
				<view class="right-img-box">
					<navigator class="right-img-item" url="/subpkg/goods_list/goods_list?新品">
						<img src="/static/floor/list/雷士照明灯泡.png" style="width:232rpx" mode="widthFix" />
					</navigator>
					<navigator class="right-img-item" url="/subpkg/goods_list/goods_list?新品">
						<img src="/static/floor/list/雷士照明筒灯.png" style="width:232rpx" mode="widthFix" />
					</navigator>
					<navigator class="right-img-item" url="/subpkg/goods_list/goods_list?新品">
						<img src="/static/floor/list/雷士照明吸顶灯.png" style="width:232rpx" mode="widthFix" />
					</navigator>
					<navigator class="right-img-item" url="/subpkg/goods_list/goods_list?新品">
						<img src="/static/floor/list/拳王插座工程.png" style="width:232rpx" mode="widthFix" />
					</navigator>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				//轮播图的数据列表
				swiperList: [],
				//分类导航的数据列表
				navList: [],
				//楼层的数据列表
				floorList: []
			};
		},
		onLoad() {
			//调用方法，获取轮播图的数据
			this.getSwiperList()
			//调用方法，分类导航数据
			this.getNavList()
			//调用方法，获取楼层数据
			this.getFloorList()
		},
		methods: {
			//获取轮播图数据的方法
			async getSwiperList() {
				const {
					data: res
				} = await uni.$http.get('/api/public/v1/home/swiperdata')
				if (res.meta.status !== 200) return uni.$showMsg()

				this.swiperList = res.message
				uni.$showMsg('数据请求成功！')
			},
			//获取分类导航数据的方法
			async getNavList() {
				const {
					data: res
				} = await uni.$http.get('/api/public/v1/home/catitems')
				if (res.meta.status !== 200) return uni.$showMsg()

				this.navList = res.message
				uni.$showMsg('数据请求成功！')
			},
			navigatorHandler(e) {
				uni.switchTab({
					url: '/pages/cate/cate'
				})
			},
			//调用方法，获取楼层数据的方法
			async getFloorList() {
				const {
					data: res
				} = await uni.$http.get('/api/public/v1/home/floordata')
				if (res.meta.status !== 200) return uni.$showMsg()

				this.floorList = res.message
				uni.$showMsg('数据请求成功！')
			}
		}
	}
</script>

<style lang="scss">
	swiper {
		height: 330rpx;

		.swiper-item,
		image {
			height: 100%;
			width: 100%;
		}
	}

	.nav-list {
		display: flex;
		justify-content: space-around;
		margin: 15px 0;
	}

	.nav-img {
		width: 98rpx;
		height: 85rpx;
	}

	.nav-text {
		font-size: 30rpx;
		margin-top: 10rpx;
	}

	.nav-item {
		flex-direction: column;
		justify-content: center;
		align-items: center;
		display: flex;
	}

	.floor-title {
		width: 160rpx;
		height: 60rpx;
	}

	.right-img-box {
		display: flex;
		flex-wrap: wrap;
		justify-content: space-around;
	}

	.floor-img-box {
		display: flex;
		padding-left: 10rpx;
	}
</style>